{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on package cntext:\n",
      "\n",
      "NAME\n",
      "    cntext\n",
      "\n",
      "PACKAGE CONTENTS\n",
      "    dictionary\n",
      "    mind\n",
      "    similarity\n",
      "    stats\n",
      "\n",
      "FILE\n",
      "    /Library/Frameworks/anaconda3/lib/python3.9/site-packages/cntext/__init__.py\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import cntext as ct\n",
    "\n",
    "help(ct)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on module cntext.similarity in cntext:\n",
      "\n",
      "NAME\n",
      "    cntext.similarity - # -*- coding: utf-8 -*-\n",
      "\n",
      "FUNCTIONS\n",
      "    cosine_sim(text1, text2)\n",
      "        cosine similarity algorithm;\n",
      "        :param text1:  text string\n",
      "        :param text2:  text string\n",
      "        :return:\n",
      "    \n",
      "    jaccard_sim(text1, text2)\n",
      "        jaccard similarity algorithm;\n",
      "        :param text1:  text string\n",
      "        :param text2:  text string\n",
      "        :return:\n",
      "    \n",
      "    minedit_sim(text1, text2)\n",
      "        Minimum edit distance similarity algorithm;\n",
      "        :param text1:  text string\n",
      "        :param text2: text string\n",
      "        :return:\n",
      "    \n",
      "    simple_sim(text1, text2)\n",
      "        simple similarity algorithm;\n",
      "        Refer to the track change function in Microsoft Word and the diff function in Unix systems.\n",
      "        :param text1:  text string\n",
      "        :param text2: text string\n",
      "        :return:\n",
      "\n",
      "FILE\n",
      "    /Library/Frameworks/anaconda3/lib/python3.9/site-packages/cntext/similarity.py\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(ct.similarity)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Building prefix dict from the default dictionary ...\n",
      "Loading model from cache /var/folders/sc/3mnt5tgs419_hk7s16gq61p80000gn/T/jieba.cache\n",
      "Loading model cost 0.592 seconds.\n",
      "Prefix dict has been built successfully.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.82\n",
      "0.67\n",
      "1.00\n",
      "0.84\n"
     ]
    }
   ],
   "source": [
    "import cntext as ct \n",
    "\n",
    "\n",
    "text1 = '编程真好玩编程真好玩'\n",
    "text2 = '游戏真好玩编程真好玩'\n",
    "\n",
    "print(ct.cosine_sim(text1, text2))\n",
    "print(ct.jaccard_sim(text1, text2))\n",
    "print(ct.minedit_sim(text1, text2))\n",
    "print(ct.simple_sim(text1, text2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import cntext as ct \n",
    "\n",
    "\n",
    "text1 = 'Programming is fun Programming is fun'\n",
    "text2 = 'Programming is interesting Programming is fun'\n",
    "\n",
    "print(ct.cosine_sim(text1, text2))\n",
    "print(ct.jaccard_sim(text1, text2))\n",
    "print(ct.minedit_sim(text1, text2))\n",
    "print(ct.simple_sim(text1, text2))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
